﻿#------------------------------------------------------------------------
# Source File Information (DO NOT MODIFY)
# Source ID: c513967a-a4e8-435f-80d1-4fbbd9a971e7
# Source File: main_form_new.psf
#------------------------------------------------------------------------
#region File Recovery Data (DO NOT MODIFY)
<#RecoveryData:
yVoAAB+LCAAAAAAABADlXOtv4joW/77S/R8iPt0dsS0Jr3K3RWphHui20wqYdj+shExiaHZCjBLT
x2r++D1OAgTiJLZL0nJXM5oOxfY59vn5PG2fD7FJnrD32kcUafAf3ybuRcU40Svd3/6maee3nj23
XeR8sR38HS1wd4FsdzIj3mLi4ueTpT87P020CXtO/4NNqtHXJb6ojF59ihcnD7ZrkWf/5Av0D/+t
aryvqtp9xErjpMb+VLXeyqErD1+4eEU95FS1u9XUsc0/8euY/MTuxbTdRk2z2dI79QaunXUqmgus
XFRugF82ZkUzH23H8qBppUdc6hHHD+cIvN55ZIk9+hr1uVxRMjKRg/v2AruMD2jaqmp6/fx03TSv
6w2xcKX7BSiJ9bH/C83H3grnNu85NnZp2OGs06xqrUYtt9MNerEX0OWKvABXyPHz6TBRVrrr9ctt
PqLIo3fEtymsV6XbAx6xNzI9jN3cvmP8Qivd4d2ldgl/f4xvby7Hg9vv2ujH3d3tcJzs//kJho86
XxNkbfmcsI/np0GDdet8KN4hFzuFY3HJqAxus6CYXJtrYqJwSfWqVm80E4uRJrmImkD7EEu6Dlgy
arpAhzGaDlwLA5TqnC1xGq63+OqPAST3Nn4uXACM0BMQGiP/57XtUzlJXCHzZ484xKt0Hx5tmtxB
nC7Es2AX0FeHKQP7BVsj2507Il23cocJG4aw2PfnKNIRdFVs3tBgAFLIkxjrVZzEYtwwflyfItfE
feybnr2kxBviGQa5mXiN4YCPScTHJOBjsmZzole00/j8TtkE/8oTPvt/m7CeLWIJLQiGvtkWUbNb
LZi0v3s2irF4Q1Y+/sa8reQmnew22LVfe2NdzphhxQ4oVc5AsW8zR+kTEA8GX8L8yRkl9u2eLZVW
7mWaVndGeo8YZqRqYQ2jqv1DxALGTeyaqjDG2q0OYKxzJoUxo8Vrnr/+VytKiVu4AKYBmWAd7pGz
Auxg5GXLIUsSbaMOVo8z4zRRcOkL9Q9l0mgAvaQzky2TekOsQ+DeinP0wwd3yF8hJ3AcYm4HNz5I
bO1oU3NXZMLZ04ld/fFwdd8fvBFQjQ4ImKenswG1Jlw4kgQ7vCOS1ktxOAix2UBAWjiGHDTFTp+w
1MVn90kWQzs+/HfipqxbKvIMBoi2BPJ22RXqOMTIunWd1yzBcsHa0rlpjRywiinmEKzhRH7xZ/Lh
UcP8srIBo7cBMDxrnwkYxmmxWGkYKljheVNpWEmZw4dHyTtolbOmAkYKVyf1ugpExMxyCJEj1SOh
FiwbJC0FjIScFguTporVMTrSVufIkEKBzpS8bF12WbywSkKPLJYOplEBYrSazzE3CZjde0RWngn9
eyufkkX4SRJ8TaYLWjKOT2L+EpCKsteSmEoDYdwJZtLvPSJ3ji0Oi5PY1/s+8d5A8QRQcpyM7M8H
hmygMmAWanh9q35rnql4Sht2i1VyuqFiDA1eVig1EMzaKR8eNhBQlg2YerOmEIsBowVDRW+rQEVs
IiFUYA7a9WCUrKUeQfZnhJ6kVcteOGXUZNTElqyMU2Mo5H0MmQyiMEOHTPswokeaNRxRslTHTaej
CBugKpOB6SjARufVp1JhI8rQQWEDRA8HG3BLp6QMw2QyQuCYqcVrjBtEqe3OP7to6jCHUdgS7ERt
hph8Q9jt8iwDPaaxBPMzW+jlAyEsP2Ir6LFxnXfZnPAaHQIq7CTbV8+2SjlQYgGxORBjxdMh9mEU
6ZDNccgzbDxvTC4tawhMpp3Pyundxyxue8MAt8y1gg2/WrDjbsK4DXt8A9cHFvUbtuePwdm0MPxc
H22T3AHsxEtDRvMm5VCUwwYLHM31wbboY3KqIEfHiZqIjjjGEHUjivfOROw1DBcXfAa+tVCbnri2
aLfASa03BXP/W33BrVsfgw1QyOoexgCw3K6SBRDN78YcVln1nyJ+cfUPPBam+0v1LkFdS4evcZcK
uf4SQVcxVbUXz+gtGXxsGC48nJEpY4vyk+qWZpi5VL8UiB6xW6pSjjyMTtJZpVhJKQkXJiOntKmg
lQTSuNlaKThD+JdQSwpZtZ3Qoym2heOKRTQ/FtUIWwqKRSZNAuz88R6nY47vYExUhVCAzMeqNLHj
lDLhwnbeMkla5v9KV5hSNGZegYnB6U2VJTbAYUtKQ9t8LAuYHtB6czU0BpDgTJ4MQrgMSIDFCM6v
ci/TZPpPMkchJKO4B+JZDx5aCvtNO7jkLkgWRFUgds2qLeUUn74M+io6L+OeXjYEweh1pAtPwKQM
5lSKSGKbIgQcsMMzrEekTN7kHNV1WRd4l7KU+ghsjaDXs821yByReS/1kWPajsBfUtAdMRSBs9IR
E+yOsyKnCzo1BV8lRT/tXLbFrBYb42kS/OYgwTQzK9hi949KCalDcg6Qe89cX3A6XK/JBF0JzmXP
e4sWnbd6JeVQShwZ7LpdePkqyeBk82WOIxuFVMkBDhZalehi3CHfL9XH0OtNFS+D8Vn0GV+ZU02M
n0P5Ge+qVN6ziGxIhzw83iU1S1vQ/9gqFgGTk6pYokLym3RLNMaxZm5UVMxeJUHFFxHWGKzhMziO
4Ot5le4n2fKDrAPDg9+HT9j+WFqI4p6HrTeIkr1OI7XbE7QlZHOmksHVZVIbsnwdMpMbo32k594A
Oi57HUBdMQQXNBTwFFGWOVXQVMGSzKUyGZ4OevM6pHukGLo0Ayiop1zVDk+GZAvHj9S9/ZS3Hfjt
Bws0x0PsRMsQfLzCM+Jh9m3pIAzX8yjDJ4GXPA6fo9XbYqolFj6J4yO6Rqty+U2XuXIdcCQQQSm8
1FXm/RDFV7oErohkhE0Q3Io/sbbDpkCv3AN5Kb5wGmIyDkSIPBgWoiWVf3l4jCiiK/8KeYUDxA8o
TfNeBMk8Ytqqcd9t4kp6Q09YaMHTjJyXGbntIdj/6tkZufWMkmFS0juC2/2QL8PbJXbZS559Gzlk
XrgggXF3BuSsgFzai5zAEGXF7d7oXmPM+b9/OjH9p7//Cn78YkDe/J6+0OqnExiMfQsf/hl8+HXp
OJsmn9hXyWiUTzX14ON+84FrU5hF3/ZgiYkHu7z3x79h7ZKXLxLStCnTVl8x1YJ7WrAbA173OsqK
ckyIM7aXhctw9MgORTvL9QtsIpoCPeESUeYDuY+KMlHY7Er/0vfxAuaO/fWw0W9euwvfJJ5jTw+w
fuenm1H3qYQSK4PGwVGRT5FdIimHkIeeQfmr0KrVZ81Ze6brVrOG6iif1r8WTilz6kGwc3hCm48h
5M9P409Xd/8H0R8qEMlaAAA=#>
#endregion

<#
    .NOTES
    --------------------------------------------------------------------------------
     Code generated by:  SAPIEN Technologies, Inc., PowerShell Studio 2017 v5.4.138
     Generated on:       2017/9/29 1:11
     Generated by:       Chaoyue wang
     Organization:       Citi
    --------------------------------------------------------------------------------
    .DESCRIPTION
        GUI script generated by PowerShell Studio 2017
#>


#----------------------------------------------
#region Application Functions
#----------------------------------------------

#endregion Application Functions

#----------------------------------------------
# Generated Form Function
#----------------------------------------------
function Show-main_form_new_psf {

	#----------------------------------------------
	#region Import the Assemblies
	#----------------------------------------------
	[void][reflection.assembly]::Load('System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089')
	[void][reflection.assembly]::Load('System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089')
	[void][reflection.assembly]::Load('System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a')
	#endregion Import Assemblies

	#----------------------------------------------
	#region Generated Form Objects
	#----------------------------------------------
	[System.Windows.Forms.Application]::EnableVisualStyles()
	$MainForm = New-Object 'System.Windows.Forms.Form'
	$panelIO = New-Object 'System.Windows.Forms.Panel'
	$TreeviewTaskList = New-Object 'System.Windows.Forms.TreeView'
	$panelInfoCheck = New-Object 'System.Windows.Forms.Panel'
	$buttonCheckValueClear = New-Object 'System.Windows.Forms.Button'
	$buttonVDIClear = New-Object 'System.Windows.Forms.Button'
	$labelDomainEnv = New-Object 'System.Windows.Forms.TextBox'
	$labelNode = New-Object 'System.Windows.Forms.TextBox'
	$labelEnv = New-Object 'System.Windows.Forms.TextBox'
	$labelDomain = New-Object 'System.Windows.Forms.TextBox'
	$textboxCheckValue = New-Object 'System.Windows.Forms.TextBox'
	$labelChekValue = New-Object 'System.Windows.Forms.TextBox'
	$labelVDI = New-Object 'System.Windows.Forms.TextBox'
	$buttonSave = New-Object 'System.Windows.Forms.Button'
	$buttonStop = New-Object 'System.Windows.Forms.Button'
	$comboboxDomain = New-Object 'System.Windows.Forms.ComboBox'
	$datagridviewResult = New-Object 'System.Windows.Forms.DataGridView'
	$comboboxEnv = New-Object 'System.Windows.Forms.ComboBox'
	$buttonAdd = New-Object 'System.Windows.Forms.Button'
	$comboboxNode = New-Object 'System.Windows.Forms.ComboBox'
	$buttonVDI = New-Object 'System.Windows.Forms.Button'
	$textboxVDI = New-Object 'System.Windows.Forms.TextBox'
	$richtextboxCheckValue = New-Object 'System.Windows.Forms.RichTextBox'
	$labelFID = New-Object 'System.Windows.Forms.Label'
	$richtextboxVDI = New-Object 'System.Windows.Forms.RichTextBox'
	$textboxFID = New-Object 'System.Windows.Forms.TextBox'
	$checkedlistboxEnv = New-Object 'System.Windows.Forms.CheckedListBox'
	$labelPass = New-Object 'System.Windows.Forms.Label'
	$checkedlistboxDomain = New-Object 'System.Windows.Forms.CheckedListBox'
	$textboxPass = New-Object 'System.Windows.Forms.TextBox'
	$buttonUpdateCreds = New-Object 'System.Windows.Forms.Button'
	$buttonConnect = New-Object 'System.Windows.Forms.Button'
	$buttonAction = New-Object 'System.Windows.Forms.Button'
	$labelCheck = New-Object 'System.Windows.Forms.Label'
	$labelTaskList = New-Object 'System.Windows.Forms.TextBox'
	$statusbar = New-Object 'System.Windows.Forms.StatusBar'
	$openfiledialog = New-Object 'System.Windows.Forms.OpenFileDialog'
	$ShowHelp = New-Object 'System.Windows.Forms.ToolTip'
	$savefiledialog = New-Object 'System.Windows.Forms.SaveFileDialog'
	$InitialFormWindowState = New-Object 'System.Windows.Forms.FormWindowState'
	#endregion Generated Form Objects

	#----------------------------------------------
	# User Generated Script
	#----------------------------------------------
	$MainForm_Load = {
	    #<------------------------------------ initilize and parameters
	    . .\functions.ps1
	    if ($env:USERNAME -inotmatch 'aaadmin') {
	        #Popup-Message "Only aaadmin(_p) can run me!" "Unautorizied User"; exit
	    }
	    
	    $MainForm.Text +=" ---- {0} | {1} | {2}" -f `
	    $env:USERNAME,$env:COMPUTERNAME,(ipconfig.exe | ?{ $_ -imatch "IPv4" } | %{ $_.split(':')[1] })
	    $script:inventory_list = cat .\config\inventory.txt -ReadCount 0 -ea 0 | ?{ ![string]::IsNullOrWhiteSpace($_) } | select -unique
	    $script:vmserver_list = cat .\config\vmservers.txt -ReadCount 0 -ea 0 | ?{ ![string]::IsNullOrWhiteSpace($_) } | select -unique
	    $script:db_config_xml = [xml](cat .\config\db_config.xml -ReadCount 0 -ea 0)
	    $script:check_item_list= cat .\VDIInfoCollect\check_items.txt -ReadCount 0 -ea 0 | ?{ ![string]::IsNullOrWhiteSpace($_) } | select -unique
	    $array = New-Object System.Collections.ArrayList
	    #<------------------------------------ initilize domain,env,node combobox and domain,env checkedlistbox
	    'All' | %{ [void]$checkedlistboxDomain.Items.Add($_); [void]$checkedlistboxEnv.Items.Add($_) }
	    'NAM', 'EUR', 'APAC' | %{ [void]$comboboxDomain.Items.Add($_); [void]$checkedlistboxDomain.Items.Add($_) }
	    0 .. 4 | %{ [void]$comboboxNode.Items.Add($_) }
	    'PROD', 'UAT', 'DEV', 'POC', 'LAB','COB' | %{ [void]$comboboxEnv.Items.Add($_); [void]$checkedlistboxEnv.Items.Add($_) }
	    #$comboboxDomain, $comboboxEnv,$comboboxNode|%{$_.SelectedIndex = 0}
	    #<------------------------------------ initilize fid and check value text box source array
	    [void]$textboxVDI.AutoCompleteCustomSource.AddRange(($script:inventory_list | %{ $_.split(',')[0] }))
	    [void]$textboxCheckValue.AutoCompleteCustomSource.AddRange($script:check_item_list)
	}
	
	function Update-ListBox
	{
		param
		(
			[Parameter(Mandatory = $true)]
			[ValidateNotNull()]
			[System.Windows.Forms.ListBox]
			$ListBox,
			[Parameter(Mandatory = $true)]
			[ValidateNotNull()]
			$Items,
			[Parameter(Mandatory = $false)]
			[string]
			$DisplayMember,
			[switch]
			$Append
		)
		
		if (-not $Append)
		{
			$listBox.Items.Clear()
		}
		
		if ($Items -is [System.Windows.Forms.ListBox+ObjectCollection])
		{
			$listBox.Items.AddRange($Items)
		}
		elseif ($Items -is [Array])
		{
			$listBox.BeginUpdate()
			foreach ($obj in $Items)
			{
				$listBox.Items.Add($obj)
			}
			$listBox.EndUpdate()
		}
		else
		{
			$listBox.Items.Add($Items)
		}
		
		$listBox.DisplayMember = $DisplayMember
	}
	
	function Update-DataGridView
	{
		Param (
			[ValidateNotNull()]
			[Parameter(Mandatory=$true)]
			[System.Windows.Forms.DataGridView]$DataGridView,
			[ValidateNotNull()]
			[Parameter(Mandatory=$true)]
			$Item,
		    [Parameter(Mandatory=$false)]
			[string]$DataMember,
			[System.Windows.Forms.DataGridViewAutoSizeColumnMode]$AutoSizeColumns = 'None'
		)
		$DataGridView.SuspendLayout()
		$DataGridView.DataMember = $DataMember
		
		if ($Item -is [System.Data.DataSet] -and $Item.Tables.Count -gt 0)
		{
			$DataGridView.DataSource = $Item.Tables[0]
		}
		elseif ($Item -is [System.ComponentModel.IListSource]`
		-or $Item -is [System.ComponentModel.IBindingList] -or $Item -is [System.ComponentModel.IBindingListView] )
		{
			$DataGridView.DataSource = $Item
		}
		else
		{
			$array = New-Object System.Collections.ArrayList
			
			if ($Item -is [System.Collections.IList])
			{
				$array.AddRange($Item)
			}
			else
			{
				$array.Add($Item)
			}
			$DataGridView.DataSource = $array
		}
		
		if ($AutoSizeColumns -ne 'None')
		{
			$DataGridView.AutoResizeColumns($AutoSizeColumns)
		}
		
		$DataGridView.ResumeLayout()
	}
	
	function ConvertTo-DataTable{
		[OutputType([System.Data.DataTable])]
		param(
		[ValidateNotNull()]
		$InputObject, 
		[ValidateNotNull()]
		[System.Data.DataTable]$Table,
		[switch]$RetainColumns,
		[switch]$FilterWMIProperties)
		
		if($null -eq $Table){
			$Table = New-Object System.Data.DataTable
		}	
		if ($InputObject -is [System.Data.DataTable]){
			$Table = $InputObject
		}elseif ($InputObject -is [System.Data.DataSet] -and $InputObject.Tables.Count -gt 0){
			$Table = $InputObject.Tables[0]
		}else{
			if (-not $RetainColumns -or $Table.Columns.Count -eq 0){
				#Clear out the Table Contents
				$Table.Clear()
				
				if ($null -eq $InputObject) { return } #Empty Data
				
				$object = $null
				#find the first non null value
				foreach ($item in $InputObject){
					if ($null -ne $item){
						$object = $item
						break
					}
				}
				
				if ($null -eq $object) { return } #All null then empty
				
				#Get all the properties in order to create the columns
				foreach ($prop in $object.PSObject.Get_Properties()){
					if (-not $FilterWMIProperties -or -not $prop.Name.StartsWith('__')){ #filter out WMI properties
						#Get the type from the Definition string
						$type = $null
						
						if ($null -ne $prop.Value){
							try { $type = $prop.Value.GetType() }
							catch { Out-Null }
						}
						
						if ($null -ne $type){ # -and [System.Type]::GetTypeCode($type) -ne 'Object')
							[void]$table.Columns.Add($prop.Name, $type)
						}else{ #Type info not found
							[void]$table.Columns.Add($prop.Name)
						}
					}
				}
				
				if ($object -is [System.Data.DataRow]){
					foreach ($item in $InputObject){
						$Table.Rows.Add($item)
					}
					return @( ,$Table)
				}
			}else{
				$Table.Rows.Clear()
			}
			
			foreach ($item in $InputObject){
				$row = $table.NewRow()
				
				if ($item){
					foreach ($prop in $item.PSObject.Get_Properties()){
						if ($table.Columns.Contains($prop.Name)){
							$row.Item($prop.Name) = $prop.Value
						}
					}
				}
				[void]$table.Rows.Add($row)
			}
		}
		
		return @(,$Table)	
	}
	
	function Update-ComboBox{	
		param(
			[Parameter(Mandatory = $true)]
			[ValidateNotNull()]
			[System.Windows.Forms.ComboBox]
			$ComboBox,
			[Parameter(Mandatory = $true)]
			[ValidateNotNull()]
			$Items,
			[Parameter(Mandatory = $false)]
			[string]$DisplayMember,
			[switch]$Append
		)
		
		if (-not $Append){
			$ComboBox.Items.Clear()
		}
		
		if ($Items -is [Object[]]){
			$ComboBox.Items.AddRange($Items)
		}elseif ($Items -is [System.Collections.IEnumerable]){
			$ComboBox.BeginUpdate()
			foreach ($obj in $Items){
				$ComboBox.Items.Add($obj)
			}
			$ComboBox.EndUpdate()
		}else{
			$ComboBox.Items.Add($Items)
		}
		$ComboBox.DisplayMember = $DisplayMember
	}
	
	function Get-CheckedNode
	{
		param (
				[ValidateNotNull()]
				[System.Windows.Forms.TreeNodeCollection]$NodeCollection,
				[ValidateNotNull()]
				[System.Collections.ArrayList]$CheckedNodes
		)
		
		foreach ($Node in $NodeCollection)
		{
			if ($Node.Checked)
			{
				[void]$CheckedNodes.Add($Node)
			}
			Get-CheckedNode $Node.Nodes $CheckedNodes
		}
	}
	
	$buttonVDI_Click={
	    If ($openfiledialog.ShowDialog() -ieq 'ok') {
	        $vdi_file = $openfiledialog.FileName
	        $textboxVDI.Text = $vdi_file
	        if (Test-Path $vdi_file -ea 0) {
	            if ($script:check_type -imatch 'filecheck') {
	                try {
	                    ii $vdi_file
	                } catch {
	                    [void][System.Windows.Forms.MessageBox]::Show($_, 'File Opening Error', 'OK', 'Error')
	                }
	            } else {
	                $richtextboxVDI.Clear()
	                $richtextboxVDI.LoadFile($vdi_file, 'PlainText')
	            }
	            
	        }
	    }
	}
	
	$TreeviewTaskList_NodeMouseHover=[System.Windows.Forms.TreeNodeMouseHoverEventHandler]{
	    $ShowHelp.SetToolTip($TreeviewTaskList, $_.Node.ToolTipText)
	}
	$buttonAction_Click = {
	    $task_tag = $TreeviewTaskList.SelectedNode.Tag ; $task_text = $TreeviewTaskList.SelectedNode.Text
	    $buttonAction.Enabled = $false
	    $vdi_list = $richtextboxVDI.text
	    $check_value = $richtextboxCheckValue.Text
	    switch -regex ($task_tag) {
	        'infocheck' {
	            $buttonAction.Text = "Checking"; $Global:check_result = @()
	            switch -regex ($task_text) {
	            	'aaoption' {
	            		#<code>
	            	}
	            	default {
	                    If (![string]::IsNullOrWhiteSpace($vdi_list) -and ![string]::IsNullOrWhiteSpace($check_value)) {
	                        Try {
	                            .\VDIInfoCollect\get_checked_result.ps1 $vdi_list $check_value $script:check_type
	                            $array.Clear(); $array.AddRange($Global:check_result)
	                            $datagridviewResult.DataSource = $array
	                            $MainForm.refresh()
	                        } Catch {
	                            [void][System.Windows.Forms.MessageBox]::Show($_, 'Script Running Error', 'OK', 'Error')
	                        } Finally {
	                            $buttonAction.Text = "Check"; $buttonAction.Enabled = $true
	                        }
	                    }
	            	}
	            }
	        }
	        'io' {
	            #<code>
	        }
	        'Setup' {
	            switch -regex ($task_text) {
	            	'groupmember' {
	                    If (![string]::IsNullOrWhiteSpace($vdi_list) -and ![string]::IsNullOrWhiteSpace($check_value)) {
	                        try {
	                        	# run vdi grp member master script
	                        }catch {
	                        }    
	                    }
	                }
	                'ExecutionFile' {
	                    $buttonAction.Text = "Running"
	                    If (![string]::IsNullOrWhiteSpace($vdi_list) -and ![string]::IsNullOrWhiteSpace($check_value)) {
	                        Try {
	                            #.\VDIInfoCollect\get_checked_result.ps1 $vdi_list $check_value $script:check_type
	
	                        } Catch {
	                            [void][System.Windows.Forms.MessageBox]::Show($_, 'Script Running Error', 'OK', 'Error')
	                        } Finally {
	                            $buttonAction.Text = "Run"; $buttonAction.Enabled = $true
	                        }
	                    }
	                }
	                default {
	            		#<code>
	            	}
	            }
	        }
	        default {
	            #<code>
	        }
	    }
	}
	
	$buttonStop_Click={
	    $buttonStop.Enabled = $false; $buttonStop.Text = "Stoping"
	    $Global:check_result = @()
	    $vdi_list = $richtextboxVDI.text; $stop_value = $richtextboxCheckValue.Text
	    If (![string]::IsNullOrWhiteSpace($vdi_list) -and ![string]::IsNullOrWhiteSpace($stop_value)) {
	        Try {
	            .\VDISetup\stop_master.ps1 $vdi_list $stop_value $script:check_type
	            $array.Clear(); $array.AddRange($Global:check_result)
	            $datagridviewResult.DataSource = $array
	            $MainForm.refresh()
	        } Catch {
	            [void][System.Windows.Forms.MessageBox]::Show($_, 'Script Running Error', 'OK', 'Error')
	        } Finally {
	            $buttonStop.Text = "Stop"; $buttonStop.Enabled = $true
	        }
	    }
	}
	$TreeviewTaskList_AfterSelect = [System.Windows.Forms.TreeViewEventHandler]{
	    $text = $_.Node.Text; $script:check_type = $_.Node.Text
	    $statusbar.Text = "You have selected $text task."
	    switch ($_.Node.Tag) {
	        'InfoCheck' {
	            $panelInfoCheck.BringToFront()
	            $labelCheck.Text = switch ($text) {
	                'VDIGroupMember' { "Group:" ; break;}
	            	default { "$text`:" }
	            }
	    		switch -regex ($text) {
	                "aaoptions|reboottime|loginuser" { $textboxCheckValue.Hide(); $richtextboxCheckValue.Text = $_; break; }
	                default { $textboxCheckValue.Show(); if ($text -imatch 'group') { $richtextboxCheckValue.Text= 'Administrators' } }
	            }
	        }
	        'IO' {
	            $panelIO.BringToFront()
	    	}
	        'Setup' {
	            $panelInfoCheck.BringToFront(); $richtextboxCheckValue.Clear(); $buttonAction.Text="SetUp"
	            switch -regex ($text) {
	                'VDIGroupMember' { $lc_text = 'Group:'; $lcv_text = "AddGrps"; $r_text = "Administrators`n"; $buttonAction.Text = "Set"; break; }
	                'ExecutionFile'  { $lc_text = "File:"; $lcv_text = "RunFile"; $r_text = "C:\Users\#fid\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\runClientLogin.lnk"; $buttonAction.Text = "Run"; break; }
	                default { $lc_text = "$_`:"; $lcv_text ="SetValue" }
	            }
	            $labelCheck.Text = $lc_text; $labelChekValue.Text = $lcv_text; $richtextboxCheckValue.Text= $r_text
	        }
	        default {
	    		#<code>
	    	}
	    }
		
	}
	
	$textboxVDI_MouseHover = {
	    $ShowHelp.SetToolTip($textboxVDI, $textboxVDI.Text)
	}
	
	$comboboxDomain_SelectedIndexChanged = {
	    if ($comboboxNode.Text -ne '') {
	    	If ($comboboxNode.Text -ne '0') {
	            $domain, $env, $node = $comboboxDomain.Text.ToLower(), $comboboxEnv.Text.ToLower(), ("cr" + $comboboxNode.Text.ToLower())
	            $vdi = $script:db_config_xml.SelectSingleNode("//$domain/$env/$node").'#text'
	            If (![string]::IsNullOrWhiteSpace($vdi)) {
	                $fid = Switch -regex ($env) {
	                    "prod"{ 'aaadmin_p'; break }
	                    default { 'aaadmin' }
	                }
	                Try {
	                    $plain_pass = [Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::SecureStringToBSTR((ConvertTo-SecureString ($script:db_config_xml.SelectSingleNode("//credentials/$fid/pwd").'#text') -ea 0))) 2>$null
	                } Catch { } Finally { }
	                $r_text = $richtextboxVDI.Text
	                If ($r_text -inotmatch $vdi) {
	                    if ($r_text[-1] -imatch "`n") { $add_text = "$vdi`n" } elseif ($r_text -ne '') { $add_text = "`n$vdi`n" } else { $add_text = "$vdi`n" }
	                    $richtextboxVDI.AppendText($add_text)
	                }
	                $textboxVDI.Text, $textboxFID.Text, $textboxPass.Text = $vdi, "nam\$fid", $plain_pass
	            } else {
	                $textboxVDI.Text, $textboxFID.Text, $textboxPass.Text = '', '', ''
	            }
	        } else {
	            $domain, $env = $comboboxDomain.Text, $comboboxEnv.Text
	            $new_vdis = ($script:inventory_list -imatch "$domain,$env")
	            $currentvdis_in_richtextboxVDI = $richtextboxVDI.Lines
	            $richtextboxVDI.Clear()
	            ($new_vdis + $currentvdis_in_richtextboxVDI) | select -Unique | %{ $richtextboxVDI.AppendText("$_`n") }
	        }
	    }
	    
	}
	$comboboxEnv_SelectedIndexChanged = { Invoke-Command $comboboxDomain_SelectedIndexChanged }
	$comboboxNode_SelectedIndexChanged = { Invoke-Command $comboboxDomain_SelectedIndexChanged }
	$textboxCheckValue_TextChanged = {
	    $c_text = $textboxCheckValue.Text; $r_text=$richtextboxCheckValue.text
		if ($c_text -in $script:check_item_list -and $r_text -inotmatch [regex]::Escape($c_text)) {
	        if ($r_text[-1] -imatch "`n") {$add_text= "$c_text`n"}elseif($r_text -ne '') { $add_text= "`n$c_text`n"}else{ $add_text = "$c_text`n"}
	        $richtextboxCheckValue.AppendText($add_text)
	    }
	}
	$checkedlistboxDomain_Click = {
	    $select_index = $checkedlistboxDomain.SelectedIndex
	    switch ($checkedlistboxDomain.GetItemChecked($select_index)) {
	    	$true { $checkedlistboxDomain.SetItemChecked($select_index, $false) ; break;}
	    	$false  { $checkedlistboxDomain.SetItemChecked($select_index, $true);  }
	    }
	
	}
	$checkedlistboxEnv_Click = {
	    $select_index = $checkedlistboxEnv.SelectedIndex
	    switch ($checkedlistboxEnv.GetItemChecked($select_index)) {
	        $true { $checkedlistboxEnv.SetItemChecked($select_index, $false); break; }
	        $false  { $checkedlistboxEnv.SetItemChecked($select_index, $true); }
	    }
	    
	}
	$checkedlistboxDomain_ItemCheck=[System.Windows.Forms.ItemCheckEventHandler]{
	    $this_arg = $_
	    if ($this_arg.Index -eq 0) {
	    	if ($this_arg.CurrentValue -eq 'Unchecked') {
	            1 .. ($checkedlistboxDomain.Items.Count - 1) | %{ $checkedlistboxDomain.SetItemChecked($_, $true) }
	        }
	    }else {
	    	if ($this_arg.CurrentValue -eq 'Checked') {
	            $checkedlistboxDomain.SetItemChecked(0, $false)
	        }
	    }
	    
	}
	$checkedlistboxEnv_ItemCheck=[System.Windows.Forms.ItemCheckEventHandler]{
	    $this_arg = $_
	    if ($this_arg.Index -eq 0) {
	        if ($this_arg.CurrentValue -eq 'Unchecked') {
	            1 .. ($checkedlistboxEnv.Items.Count - 1) | %{ $checkedlistboxEnv.SetItemChecked($_, $true) }
	        }
	    } else {
	        if ($this_arg.CurrentValue -eq 'Checked') {
	            $checkedlistboxEnv.SetItemChecked(0, $false)
	        }
	    }
	}
	$buttonConnect_Click={
	    $vdi, $fid, $pass = $textboxVDI.Text, $textboxFID.text, $textboxPass.Text
	    cmdkey.exe /generic:$vdi /user:$fid /pass:$pass 1>$null 2>&1
	    Try {
	        If ($script:vmserver_list -imatch $vdi) {
	            mstsc.exe /v $vdi
	        } else {
	            mstsc.exe /v $vdi /w 1376 /h 768
	        }
	    } Catch {
	        [void][System.Windows.Forms.MessageBox]::Show($_, 'RDC Connecting Error', 'OK', 'Error')
	    } Finally { }
	}
	$buttonUpdateCreds_Click = {
	    if ($richtextboxCheckValue.Text -eq "") {
	        Write-Host "new line"
	    }else{ Write-Host "no line"}
	    
	}
	$buttonAdd_Click = {
	    $vdi_list=@()
	    foreach ($d in ($checkedlistboxDomain.CheckedItems|?{$_ -ine 'all'})) {
	        foreach ($e in ($checkedlistboxEnv.CheckedItems | ?{ $_ -ine 'all' })) {
	            $vdi_list+= $script:inventory_list -imatch "$d,$e"
	        }
	    }
	    $currentvdis_in_richtextboxVDI = $richtextboxVDI.Lines
	    $richtextboxVDI.Clear()
	    ($vdi_list + $currentvdis_in_richtextboxVDI)| select -Unique | %{ $richtextboxVDI.AppendText("`n$_") }
	}
	
	$buttonSave_Click={
	    if ($savefiledialog.ShowDialog() -ieq 'ok') {
	        $save_file = $savefiledialog.FileName
	        if ($global:check_result -ne $null) {
	            switch -regex ($save_file) {
	                'csv$' {
	                    try {
	                        $global:check_result| Export-Csv $save_file -NoTypeInformation -Force -Encoding UTF8 -ea 1
	                    } catch {
	                        [void][System.Windows.Forms.MessageBox]::Show($_, 'Saving File Error', 'OK', 'Error')
	                    }
	                    break}
	                'txt$'  {
	                    try {
	                        $global:check_result| Out-File $save_file -Encoding UTF8 -Force -ea 1
	                    } catch {
	                        [void][System.Windows.Forms.MessageBox]::Show($_, 'Saving File Error', 'OK', 'Error')
	                    }
	                }
	            } 
	        }
	    }
	}
	
	$textboxVDI_TextChanged = {
	    $v_text = $textboxVDI.Text; $r_text=$richtextboxVDI.Text
	    if ($v_text -imatch '^\w{12,}') {
	        if ($r_text -inotmatch [regex]::Escape($v_text)) {
	            if ($r_text[-1] -imatch "`n") { $add_text = "$v_text`n" } elseif ($r_text -ne '') { $add_text = "`n$v_text`n" } else { $add_text = "$v_text`n" }
	            $richtextboxVDI.AppendText($add_text)
	        }
	    }
	}
	
	$textboxFID_Leave = {
	    if ($textboxFID.Text -inotmatch [regex]::new("(nam|apac|eur)\\\w{7,9}\b")) {
	        [void][System.Windows.Forms.MessageBox]::Show("FID value should matches one or more of below requirements`
        `n 1. Must start with one of `"nam,apac,eur`"
        `n 2. FID itselves' length must be 7-9"`
	        , 'FID Syntaxt Error', 'OK', 'Error')
	    }
	}
	$textboxCheckValue_MouseHover={
	    $ShowHelp.SetToolTip($textboxCheckValue, $textboxCheckValue.Text)
	}
	
	$richtextboxVDI_TextChanged = {
	    $labelVDI.Text = "VDI LIST(line {0})" -f $richtextboxVDI.Lines.count
	}
	
	$richtextboxCheckValue_TextChanged = {
	    $rcv_line = $richtextboxCheckValue.Lines.count
	    $labelChekValue.Text = "CheckValue(line {0})" -f $rcv_line
	    if ($TreeviewTaskList.SelectedNode.Text -imatch 'ExecutionFile') {
	        if ($rcv_line -eq 1 -or $richtextboxCheckValue.Lines[-1].Trim() -eq '') {} else {
	            Popup-Message "Only one execution file is allowed to be ran one time!" #"Invalid Execution File Count"
	            $richtextboxCheckValue.Clear(); $labelChekValue.Text = "CheckValue(line 0)"
	        }
	    }
	}
	
	$buttonVDIClear_Click={$richtextboxVDI.Clear()}
	$buttonCheckValueClear_Click={$richtextboxCheckValue.Clear()}
	
	$TreeviewTaskList_DoubleClick={
		if ($_.Node.Text -ieq 'UpdateInventory') {
	    	Update-Inventory
	    }
	}
	
	# --End User Generated Script--
	#----------------------------------------------
	#region Generated Events
	#----------------------------------------------
	
	$Form_StateCorrection_Load=
	{
		#Correct the initial state of the form to prevent the .Net maximized form issue
		$MainForm.WindowState = $InitialFormWindowState
	}
	
	$Form_Cleanup_FormClosed=
	{
		#Remove all event handlers from the controls
		try
		{
			$TreeviewTaskList.remove_NodeMouseHover($TreeviewTaskList_NodeMouseHover)
			$TreeviewTaskList.remove_AfterSelect($TreeviewTaskList_AfterSelect)
			$TreeviewTaskList.remove_DoubleClick($TreeviewTaskList_DoubleClick)
			$buttonCheckValueClear.remove_Click($buttonCheckValueClear_Click)
			$buttonVDIClear.remove_Click($buttonVDIClear_Click)
			$textboxCheckValue.remove_TextChanged($textboxCheckValue_TextChanged)
			$textboxCheckValue.remove_MouseHover($textboxCheckValue_MouseHover)
			$buttonSave.remove_Click($buttonSave_Click)
			$buttonStop.remove_Click($buttonStop_Click)
			$comboboxDomain.remove_SelectedIndexChanged($comboboxDomain_SelectedIndexChanged)
			$comboboxEnv.remove_SelectedIndexChanged($comboboxEnv_SelectedIndexChanged)
			$buttonAdd.remove_Click($buttonAdd_Click)
			$comboboxNode.remove_SelectedIndexChanged($comboboxNode_SelectedIndexChanged)
			$buttonVDI.remove_Click($buttonVDI_Click)
			$textboxVDI.remove_TextChanged($textboxVDI_TextChanged)
			$textboxVDI.remove_MouseHover($textboxVDI_MouseHover)
			$richtextboxCheckValue.remove_TextChanged($richtextboxCheckValue_TextChanged)
			$richtextboxVDI.remove_TextChanged($richtextboxVDI_TextChanged)
			$textboxFID.remove_Leave($textboxFID_Leave)
			$checkedlistboxEnv.remove_ItemCheck($checkedlistboxEnv_ItemCheck)
			$checkedlistboxEnv.remove_Click($checkedlistboxEnv_Click)
			$checkedlistboxDomain.remove_ItemCheck($checkedlistboxDomain_ItemCheck)
			$checkedlistboxDomain.remove_Click($checkedlistboxDomain_Click)
			$buttonUpdateCreds.remove_Click($buttonUpdateCreds_Click)
			$buttonConnect.remove_Click($buttonConnect_Click)
			$buttonAction.remove_Click($buttonAction_Click)
			$MainForm.remove_Load($MainForm_Load)
			$MainForm.remove_Load($Form_StateCorrection_Load)
			$MainForm.remove_FormClosed($Form_Cleanup_FormClosed)
		}
		catch { Out-Null <# Prevent PSScriptAnalyzer warning #> }
	}
	#endregion Generated Events

	#----------------------------------------------
	#region Generated Form Code
	#----------------------------------------------
	$MainForm.SuspendLayout()
	$panelInfoCheck.SuspendLayout()
	#
	# MainForm
	#
	$MainForm.Controls.Add($panelIO)
	$MainForm.Controls.Add($TreeviewTaskList)
	$MainForm.Controls.Add($panelInfoCheck)
	$MainForm.Controls.Add($labelTaskList)
	$MainForm.Controls.Add($statusbar)
	$MainForm.AutoScaleDimensions = '6, 13'
	$MainForm.AutoScaleMode = 'Font'
	$MainForm.AutoSize = $True
	$MainForm.ClientSize = '895, 640'
	$MainForm.MaximizeBox = $False
	$MainForm.Name = 'MainForm'
	$MainForm.StartPosition = 'CenterScreen'
	$MainForm.Text = 'RPA AA AUTOMATION SUPPORT'
	$MainForm.add_Load($MainForm_Load)
	#
	# panelIO
	#
	$panelIO.Location = '1, 345'
	$panelIO.Name = 'panelIO'
	$panelIO.Size = '115, 201'
	$panelIO.TabIndex = 33
	#
	# TreeviewTaskList
	#
	$TreeviewTaskList.BackColor = 'White'
	$TreeviewTaskList.BorderStyle = 'FixedSingle'
	$TreeviewTaskList.Location = '0, 22'
	$TreeviewTaskList.Name = 'TreeviewTaskList'
	$System_Windows_Forms_TreeNode_2 = New-Object 'System.Windows.Forms.TreeNode' ('AAOptions')
	$System_Windows_Forms_TreeNode_2.Name = 'AAOptions'
	$System_Windows_Forms_TreeNode_2.Tag = 'infocheck'
	$System_Windows_Forms_TreeNode_2.Text = 'AAOptions'
	$System_Windows_Forms_TreeNode_2.ToolTipText = 'Get fid AA options values(to be edited)'
	$System_Windows_Forms_TreeNode_3 = New-Object 'System.Windows.Forms.TreeNode' ('Process')
	$System_Windows_Forms_TreeNode_3.Name = 'Process'
	$System_Windows_Forms_TreeNode_3.Tag = 'infocheck'
	$System_Windows_Forms_TreeNode_3.Text = 'Process'
	$System_Windows_Forms_TreeNode_3.ToolTipText = 'Check if given process can be found'
	$System_Windows_Forms_TreeNode_4 = New-Object 'System.Windows.Forms.TreeNode' ('RebootTime')
	$System_Windows_Forms_TreeNode_4.Name = 'RebootTime'
	$System_Windows_Forms_TreeNode_4.Tag = 'infocheck'
	$System_Windows_Forms_TreeNode_4.Text = 'RebootTime'
	$System_Windows_Forms_TreeNode_4.ToolTipText = 'Check given VDI last reboot time'
	$System_Windows_Forms_TreeNode_5 = New-Object 'System.Windows.Forms.TreeNode' ('Service')
	$System_Windows_Forms_TreeNode_5.Name = 'Service'
	$System_Windows_Forms_TreeNode_5.Tag = 'infocheck'
	$System_Windows_Forms_TreeNode_5.Text = 'Service'
	$System_Windows_Forms_TreeNode_5.ToolTipText = 'Check given service running status in the VDI'
	$System_Windows_Forms_TreeNode_6 = New-Object 'System.Windows.Forms.TreeNode' ('LoginUser')
	$System_Windows_Forms_TreeNode_6.Name = 'LoginUser'
	$System_Windows_Forms_TreeNode_6.Tag = 'InfoCheck'
	$System_Windows_Forms_TreeNode_6.Text = 'LoginUser'
	$System_Windows_Forms_TreeNode_6.ToolTipText = 'Check which user has logged in the VDI'
	$System_Windows_Forms_TreeNode_7 = New-Object 'System.Windows.Forms.TreeNode' ('VDIGroupMember')
	$System_Windows_Forms_TreeNode_7.Name = 'VDIGroupMember'
	$System_Windows_Forms_TreeNode_7.Tag = 'InfoCheck'
	$System_Windows_Forms_TreeNode_7.Text = 'VDIGroupMember'
	$System_Windows_Forms_TreeNode_7.ToolTipText = 'Check given VDI group members, default group is Administrators'
	$System_Windows_Forms_TreeNode_1 = New-Object 'System.Windows.Forms.TreeNode' ('InfoCheck', [System.Windows.Forms.TreeNode[]] ($System_Windows_Forms_TreeNode_2, $System_Windows_Forms_TreeNode_3, $System_Windows_Forms_TreeNode_4, $System_Windows_Forms_TreeNode_5, $System_Windows_Forms_TreeNode_6, $System_Windows_Forms_TreeNode_7))
	$System_Windows_Forms_TreeNode_1.Name = 'InfoCheck'
	$System_Windows_Forms_TreeNode_1.NodeFont = 'Microsoft Sans Serif, 8.25pt'
	$System_Windows_Forms_TreeNode_1.Text = 'InfoCheck'
	[void]$TreeviewTaskList.Nodes.Add($System_Windows_Forms_TreeNode_1)
	$System_Windows_Forms_TreeNode_9 = New-Object 'System.Windows.Forms.TreeNode' ('FileCheck')
	$System_Windows_Forms_TreeNode_9.Name = 'FileCheck'
	$System_Windows_Forms_TreeNode_9.Tag = 'IO'
	$System_Windows_Forms_TreeNode_9.Text = 'FileCheck'
	$System_Windows_Forms_TreeNode_9.ToolTipText = 'Get the remote VDI file content'
	$System_Windows_Forms_TreeNode_10 = New-Object 'System.Windows.Forms.TreeNode' ('Copy')
	$System_Windows_Forms_TreeNode_10.Name = 'Copy'
	$System_Windows_Forms_TreeNode_10.Tag = 'IO'
	$System_Windows_Forms_TreeNode_10.Text = 'Copy'
	$System_Windows_Forms_TreeNode_10.ToolTipText = 'Copy files among VDIs(to be edited)'
	$System_Windows_Forms_TreeNode_8 = New-Object 'System.Windows.Forms.TreeNode' ('IO', [System.Windows.Forms.TreeNode[]] ($System_Windows_Forms_TreeNode_9, $System_Windows_Forms_TreeNode_10))
	$System_Windows_Forms_TreeNode_8.Name = 'IO'
	$System_Windows_Forms_TreeNode_8.Text = 'IO'
	[void]$TreeviewTaskList.Nodes.Add($System_Windows_Forms_TreeNode_8)
	$System_Windows_Forms_TreeNode_12 = New-Object 'System.Windows.Forms.TreeNode' ('SetVDIGroupMember')
	$System_Windows_Forms_TreeNode_12.Name = 'Set VDI Group member'
	$System_Windows_Forms_TreeNode_12.Tag = 'Setup'
	$System_Windows_Forms_TreeNode_12.Text = 'SetVDIGroupMember'
	$System_Windows_Forms_TreeNode_12.ToolTipText = 'Add/Remove/Check VDI Group Member'
	$System_Windows_Forms_TreeNode_13 = New-Object 'System.Windows.Forms.TreeNode' ('UpdateInventory')
	$System_Windows_Forms_TreeNode_13.Name = 'UpdateInventory'
	$System_Windows_Forms_TreeNode_13.Tag = 'Setup'
	$System_Windows_Forms_TreeNode_13.Text = 'UpdateInventory'
	$System_Windows_Forms_TreeNode_13.ToolTipText = 'Download Inventory From Shared Document after this is double clicked'
	$System_Windows_Forms_TreeNode_14 = New-Object 'System.Windows.Forms.TreeNode' ('ExecutionFileTirgger')
	$System_Windows_Forms_TreeNode_14.Name = 'ExecutionFileTirgger'
	$System_Windows_Forms_TreeNode_14.Tag = 'Setup'
	$System_Windows_Forms_TreeNode_14.Text = 'ExecutionFileTirgger'
	$System_Windows_Forms_TreeNode_14.ToolTipText = 'Start remote VDI file like script or exe, default one is for AA client login bat in startup folder'
	$System_Windows_Forms_TreeNode_11 = New-Object 'System.Windows.Forms.TreeNode' ('Setup', [System.Windows.Forms.TreeNode[]] ($System_Windows_Forms_TreeNode_12, $System_Windows_Forms_TreeNode_13, $System_Windows_Forms_TreeNode_14))
	$System_Windows_Forms_TreeNode_11.Name = 'Setup'
	$System_Windows_Forms_TreeNode_11.Text = 'Setup'
	[void]$TreeviewTaskList.Nodes.Add($System_Windows_Forms_TreeNode_11)
	$TreeviewTaskList.Size = '116, 575'
	$TreeviewTaskList.TabIndex = 0
	$TreeviewTaskList.add_NodeMouseHover($TreeviewTaskList_NodeMouseHover)
	$TreeviewTaskList.add_AfterSelect($TreeviewTaskList_AfterSelect)
	$TreeviewTaskList.add_DoubleClick($TreeviewTaskList_DoubleClick)
	#
	# panelInfoCheck
	#
	$panelInfoCheck.Controls.Add($buttonCheckValueClear)
	$panelInfoCheck.Controls.Add($buttonVDIClear)
	$panelInfoCheck.Controls.Add($labelDomainEnv)
	$panelInfoCheck.Controls.Add($labelNode)
	$panelInfoCheck.Controls.Add($labelEnv)
	$panelInfoCheck.Controls.Add($labelDomain)
	$panelInfoCheck.Controls.Add($textboxCheckValue)
	$panelInfoCheck.Controls.Add($labelChekValue)
	$panelInfoCheck.Controls.Add($labelVDI)
	$panelInfoCheck.Controls.Add($buttonSave)
	$panelInfoCheck.Controls.Add($buttonStop)
	$panelInfoCheck.Controls.Add($comboboxDomain)
	$panelInfoCheck.Controls.Add($datagridviewResult)
	$panelInfoCheck.Controls.Add($comboboxEnv)
	$panelInfoCheck.Controls.Add($buttonAdd)
	$panelInfoCheck.Controls.Add($comboboxNode)
	$panelInfoCheck.Controls.Add($buttonVDI)
	$panelInfoCheck.Controls.Add($textboxVDI)
	$panelInfoCheck.Controls.Add($richtextboxCheckValue)
	$panelInfoCheck.Controls.Add($labelFID)
	$panelInfoCheck.Controls.Add($richtextboxVDI)
	$panelInfoCheck.Controls.Add($textboxFID)
	$panelInfoCheck.Controls.Add($checkedlistboxEnv)
	$panelInfoCheck.Controls.Add($labelPass)
	$panelInfoCheck.Controls.Add($checkedlistboxDomain)
	$panelInfoCheck.Controls.Add($textboxPass)
	$panelInfoCheck.Controls.Add($buttonUpdateCreds)
	$panelInfoCheck.Controls.Add($buttonConnect)
	$panelInfoCheck.Controls.Add($buttonAction)
	$panelInfoCheck.Controls.Add($labelCheck)
	$panelInfoCheck.Location = '122, -1'
	$panelInfoCheck.Name = 'panelInfoCheck'
	$panelInfoCheck.Size = '769, 598'
	$panelInfoCheck.TabIndex = 26
	#
	# buttonCheckValueClear
	#
	$buttonCheckValueClear.Location = '723, 2'
	$buttonCheckValueClear.Name = 'buttonCheckValueClear'
	$buttonCheckValueClear.Size = '44, 23'
	$buttonCheckValueClear.TabIndex = 34
	$buttonCheckValueClear.Text = 'Clear'
	$buttonCheckValueClear.UseVisualStyleBackColor = $True
	$buttonCheckValueClear.add_Click($buttonCheckValueClear_Click)
	#
	# buttonVDIClear
	#
	$buttonVDIClear.Location = '494, 0'
	$buttonVDIClear.Name = 'buttonVDIClear'
	$buttonVDIClear.Size = '44, 23'
	$buttonVDIClear.TabIndex = 33
	$buttonVDIClear.Text = 'Clear'
	$buttonVDIClear.UseVisualStyleBackColor = $True
	$buttonVDIClear.add_Click($buttonVDIClear_Click)
	#
	# labelDomainEnv
	#
	$labelDomainEnv.BorderStyle = 'None'
	$labelDomainEnv.Location = '244, 7'
	$labelDomainEnv.Name = 'labelDomainEnv'
	$labelDomainEnv.ReadOnly = $True
	$labelDomainEnv.Size = '61, 13'
	$labelDomainEnv.TabIndex = 32
	$labelDomainEnv.Text = 'Domain|Env'
	#
	# labelNode
	#
	$labelNode.BorderStyle = 'None'
	$labelNode.Location = '174, 6'
	$labelNode.Name = 'labelNode'
	$labelNode.ReadOnly = $True
	$labelNode.Size = '42, 13'
	$labelNode.TabIndex = 31
	$labelNode.Text = 'Node'
	#
	# labelEnv
	#
	$labelEnv.BorderStyle = 'None'
	$labelEnv.Location = '85, 6'
	$labelEnv.Name = 'labelEnv'
	$labelEnv.ReadOnly = $True
	$labelEnv.Size = '33, 13'
	$labelEnv.TabIndex = 30
	$labelEnv.Text = 'Env'
	#
	# labelDomain
	#
	$labelDomain.BorderStyle = 'None'
	$labelDomain.Location = '6, 6'
	$labelDomain.Name = 'labelDomain'
	$labelDomain.ReadOnly = $True
	$labelDomain.Size = '51, 13'
	$labelDomain.TabIndex = 29
	$labelDomain.Text = 'Domain'
	#
	# textboxCheckValue
	#
	$textboxCheckValue.AutoCompleteMode = 'Suggest'
	$textboxCheckValue.AutoCompleteSource = 'CustomSource'
	$textboxCheckValue.Location = '53, 167'
	$textboxCheckValue.Name = 'textboxCheckValue'
	$textboxCheckValue.Size = '115, 20'
	$textboxCheckValue.TabIndex = 13
	$textboxCheckValue.add_TextChanged($textboxCheckValue_TextChanged)
	$textboxCheckValue.add_MouseHover($textboxCheckValue_MouseHover)
	#
	# labelChekValue
	#
	$labelChekValue.BorderStyle = 'None'
	$labelChekValue.Location = '584, 6'
	$labelChekValue.Name = 'labelChekValue'
	$labelChekValue.ReadOnly = $True
	$labelChekValue.Size = '123, 13'
	$labelChekValue.TabIndex = 28
	$labelChekValue.Text = 'CheckValue'
	#
	# labelVDI
	#
	$labelVDI.BorderStyle = 'None'
	$labelVDI.Location = '350, 7'
	$labelVDI.Name = 'labelVDI'
	$labelVDI.ReadOnly = $True
	$labelVDI.Size = '117, 13'
	$labelVDI.TabIndex = 27
	$labelVDI.Text = 'VDI LIST'
	#
	# buttonSave
	#
	$buttonSave.Location = '174, 206'
	$buttonSave.Name = 'buttonSave'
	$buttonSave.Size = '52, 23'
	$buttonSave.TabIndex = 24
	$buttonSave.Text = 'Save'
	$buttonSave.UseVisualStyleBackColor = $True
	$buttonSave.add_Click($buttonSave_Click)
	#
	# buttonStop
	#
	$buttonStop.Location = '99, 206'
	$buttonStop.Name = 'buttonStop'
	$buttonStop.Size = '69, 23'
	$buttonStop.TabIndex = 15
	$buttonStop.Text = 'Stop'
	$buttonStop.UseVisualStyleBackColor = $True
	$buttonStop.add_Click($buttonStop_Click)
	#
	# comboboxDomain
	#
	$comboboxDomain.FormattingEnabled = $True
	$comboboxDomain.Location = '6, 25'
	$comboboxDomain.Name = 'comboboxDomain'
	$comboboxDomain.Size = '62, 21'
	$comboboxDomain.TabIndex = 1
	$comboboxDomain.add_SelectedIndexChanged($comboboxDomain_SelectedIndexChanged)
	#
	# datagridviewResult
	#
	$datagridviewResult.AllowUserToAddRows = $False
	$datagridviewResult.AllowUserToDeleteRows = $False
	$datagridviewResult.AllowUserToOrderColumns = $True
	$datagridviewResult.ColumnHeadersHeightSizeMode = 'AutoSize'
	$datagridviewResult.Location = '0, 246'
	$datagridviewResult.Name = 'datagridviewResult'
	$datagridviewResult.ReadOnly = $True
	$datagridviewResult.RowHeadersWidthSizeMode = 'AutoSizeToAllHeaders'
	$datagridviewResult.RowTemplate.Height = 23
	$datagridviewResult.RowTemplate.ReadOnly = $True
	$datagridviewResult.Size = '767, 352'
	$datagridviewResult.TabIndex = 16
	#
	# comboboxEnv
	#
	$comboboxEnv.FormattingEnabled = $True
	$comboboxEnv.Location = '85, 25'
	$comboboxEnv.Name = 'comboboxEnv'
	$comboboxEnv.Size = '52, 21'
	$comboboxEnv.TabIndex = 2
	$comboboxEnv.add_SelectedIndexChanged($comboboxEnv_SelectedIndexChanged)
	#
	# buttonAdd
	#
	$buttonAdd.BackColor = 'Transparent'
	$buttonAdd.Location = '174, 165'
	$buttonAdd.Name = 'buttonAdd'
	$buttonAdd.Size = '52, 23'
	$buttonAdd.TabIndex = 23
	$buttonAdd.Text = 'Add'
	$buttonAdd.UseVisualStyleBackColor = $False
	$buttonAdd.add_Click($buttonAdd_Click)
	#
	# comboboxNode
	#
	$comboboxNode.FormattingEnabled = $True
	$comboboxNode.Location = '161, 25'
	$comboboxNode.Name = 'comboboxNode'
	$comboboxNode.Size = '65, 21'
	$comboboxNode.TabIndex = 3
	$comboboxNode.add_SelectedIndexChanged($comboboxNode_SelectedIndexChanged)
	#
	# buttonVDI
	#
	$buttonVDI.Location = '6, 53'
	$buttonVDI.Name = 'buttonVDI'
	$buttonVDI.Size = '36, 23'
	$buttonVDI.TabIndex = 4
	$buttonVDI.Text = 'VDI:'
	$buttonVDI.UseVisualStyleBackColor = $True
	$buttonVDI.add_Click($buttonVDI_Click)
	#
	# textboxVDI
	#
	$textboxVDI.AutoCompleteMode = 'Suggest'
	$textboxVDI.AutoCompleteSource = 'CustomSource'
	$textboxVDI.Location = '59, 56'
	$textboxVDI.Name = 'textboxVDI'
	$textboxVDI.Size = '167, 20'
	$textboxVDI.TabIndex = 5
	$textboxVDI.add_TextChanged($textboxVDI_TextChanged)
	$textboxVDI.add_MouseHover($textboxVDI_MouseHover)
	#
	# richtextboxCheckValue
	#
	$richtextboxCheckValue.Location = '544, 26'
	$richtextboxCheckValue.Name = 'richtextboxCheckValue'
	$richtextboxCheckValue.Size = '223, 201'
	$richtextboxCheckValue.TabIndex = 20
	$richtextboxCheckValue.Text = ''
	$richtextboxCheckValue.WordWrap = $False
	$richtextboxCheckValue.add_TextChanged($richtextboxCheckValue_TextChanged)
	#
	# labelFID
	#
	$labelFID.AutoSize = $True
	$labelFID.Location = '6, 97'
	$labelFID.Name = 'labelFID'
	$labelFID.Size = '27, 13'
	$labelFID.TabIndex = 6
	$labelFID.Text = 'FID:'
	#
	# richtextboxVDI
	#
	$richtextboxVDI.Location = '311, 25'
	$richtextboxVDI.Name = 'richtextboxVDI'
	$richtextboxVDI.Size = '227, 204'
	$richtextboxVDI.TabIndex = 19
	$richtextboxVDI.Text = ''
	$richtextboxVDI.WordWrap = $False
	$richtextboxVDI.add_TextChanged($richtextboxVDI_TextChanged)
	#
	# textboxFID
	#
	$textboxFID.Location = '39, 94'
	$textboxFID.Name = 'textboxFID'
	$textboxFID.Size = '90, 20'
	$textboxFID.TabIndex = 7
	$textboxFID.add_Leave($textboxFID_Leave)
	#
	# checkedlistboxEnv
	#
	$checkedlistboxEnv.FormattingEnabled = $True
	$checkedlistboxEnv.Location = '244, 103'
	$checkedlistboxEnv.Name = 'checkedlistboxEnv'
	$checkedlistboxEnv.Size = '61, 124'
	$checkedlistboxEnv.TabIndex = 18
	$checkedlistboxEnv.add_ItemCheck($checkedlistboxEnv_ItemCheck)
	$checkedlistboxEnv.add_Click($checkedlistboxEnv_Click)
	#
	# labelPass
	#
	$labelPass.AutoSize = $True
	$labelPass.Location = '135, 97'
	$labelPass.Name = 'labelPass'
	$labelPass.Size = '33, 13'
	$labelPass.TabIndex = 8
	$labelPass.Text = 'Pass:'
	#
	# checkedlistboxDomain
	#
	$checkedlistboxDomain.FormattingEnabled = $True
	$checkedlistboxDomain.Location = '244, 26'
	$checkedlistboxDomain.Name = 'checkedlistboxDomain'
	$checkedlistboxDomain.Size = '61, 79'
	$checkedlistboxDomain.TabIndex = 17
	$checkedlistboxDomain.add_ItemCheck($checkedlistboxDomain_ItemCheck)
	$checkedlistboxDomain.add_Click($checkedlistboxDomain_Click)
	#
	# textboxPass
	#
	$textboxPass.Location = '174, 94'
	$textboxPass.Name = 'textboxPass'
	$textboxPass.PasswordChar = '*'
	$textboxPass.Size = '52, 20'
	$textboxPass.TabIndex = 9
	#
	# buttonUpdateCreds
	#
	$buttonUpdateCreds.Location = '6, 126'
	$buttonUpdateCreds.Name = 'buttonUpdateCreds'
	$buttonUpdateCreds.Size = '86, 23'
	$buttonUpdateCreds.TabIndex = 10
	$buttonUpdateCreds.Text = 'UpdateCreds'
	$buttonUpdateCreds.UseVisualStyleBackColor = $True
	$buttonUpdateCreds.add_Click($buttonUpdateCreds_Click)
	#
	# buttonConnect
	#
	$buttonConnect.Location = '151, 126'
	$buttonConnect.Name = 'buttonConnect'
	$buttonConnect.Size = '75, 23'
	$buttonConnect.TabIndex = 11
	$buttonConnect.Text = 'Connect'
	$buttonConnect.UseVisualStyleBackColor = $True
	$buttonConnect.add_Click($buttonConnect_Click)
	#
	# buttonAction
	#
	$buttonAction.Location = '5, 206'
	$buttonAction.Name = 'buttonAction'
	$buttonAction.Size = '75, 23'
	$buttonAction.TabIndex = 14
	$buttonAction.Text = 'Check'
	$buttonAction.TextImageRelation = 'ImageBeforeText'
	$buttonAction.UseVisualStyleBackColor = $True
	$buttonAction.add_Click($buttonAction_Click)
	#
	# labelCheck
	#
	$labelCheck.AutoSize = $True
	$labelCheck.Location = '6, 171'
	$labelCheck.Name = 'labelCheck'
	$labelCheck.Size = '41, 13'
	$labelCheck.TabIndex = 12
	$labelCheck.Text = 'Check:'
	#
	# labelTaskList
	#
	$labelTaskList.BorderStyle = 'None'
	$labelTaskList.Location = '23, 5'
	$labelTaskList.Name = 'labelTaskList'
	$labelTaskList.ReadOnly = $True
	$labelTaskList.Size = '51, 13'
	$labelTaskList.TabIndex = 32
	$labelTaskList.Text = 'TaskList'
	#
	# statusbar
	#
	$statusbar.Location = '0, 600'
	$statusbar.Name = 'statusbar'
	$statusbar.Size = '895, 40'
	$statusbar.SizingGrip = $False
	$statusbar.TabIndex = 22
	#
	# openfiledialog
	#
	$openfiledialog.Filter = 'CSV Files(*.csv)|*.csv|Text Files(*.txt,*.log)|*.txt;*.log|All Files(*.*)|*.*'
	$openfiledialog.FilterIndex = 2
	$openfiledialog.InitialDirectory = 'C:\temp'
	$openfiledialog.Title = 'Get VDI List File'
	#
	# ShowHelp
	#
	#
	# savefiledialog
	#
	$savefiledialog.Filter = 'CSV Files(*.csv)|*.csv|Text Files(*.txt,*.log)|*.txt;*.log|All Files(*.*)|*.*'
	$savefiledialog.InitialDirectory = 'C:\temp'
	$panelInfoCheck.ResumeLayout()
	$MainForm.ResumeLayout()
	#endregion Generated Form Code

	#----------------------------------------------

	#Save the initial state of the form
	$InitialFormWindowState = $MainForm.WindowState
	#Init the OnLoad event to correct the initial state of the form
	$MainForm.add_Load($Form_StateCorrection_Load)
	#Clean up the control events
	$MainForm.add_FormClosed($Form_Cleanup_FormClosed)
	#Show the Form
	return $MainForm.ShowDialog()

} #End Function

#Call the form
Show-main_form_new_psf | Out-Null
